blob: 8cb483999c8ce82c73cd05adc15078c955c12fbc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import { fail, redirect } from "@sveltejs/kit";
import { fd, auth, get, post } from "$lib/utils";
export const actions = {
default: async ({ cookies, request, url }) => {
let form = await fd(request);
try {
await post("/items", form, auth(cookies));
} catch (e) {
return fail(400, { message: e.message });
}
let success = `/${url.pathname.split("/")[1]}`;
redirect(307, success);
},
};
|